/************************************************************************

								Heroes IV
					  Copyright 2001, The 3DO Company

	------------------------------------------------------------------
  						 combat_ai_ranged_single_action.h

	$Header: $

	$NoKeywords: $

 ************************************************************************/

#if !defined( COMBAT_AI_RANGED_SINGLE_ACTION_H_INCLUDED )
#define COMBAT_AI_RANGED_SINGLE_ACTION_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "abstract_combat_ai_action.h"
#include "attack_angle.h"
#include "combat_creature_ptr.h"

// A representation of the "fire a ranged weapon" action
// For single-target weapons only (not cyclopes)
class t_combat_ai_ranged_single_action : public t_abstract_combat_ai_action
{
	public:
		t_combat_ai_ranged_single_action(t_battlefield&			battlefield,
										 t_combat_creature_ptr	target, 
										 int					range_factor,
										 bool					never_use = false, 
										 double					weight = std::numeric_limits<double>::quiet_NaN());


		t_combat_creature_ptr	get_target() const;
		int						get_range_factor() const;


		virtual void weigh_action(t_combat_ai const& owner);
		virtual void perform_action(void);

	private:
		const t_combat_creature_ptr		m_target; // Target of attack
		const int						m_range_factor; // Range factor (divides damage)

		// Internal weighing function
		static double                   get_attack_weight(t_combat_creature const& attacker,
														  t_combat_creature const& target,
														  int damage);
};

inline 
t_combat_ai_ranged_single_action::t_combat_ai_ranged_single_action( 
							      t_battlefield&		battlefield,
								  t_combat_creature_ptr	target,
								  int					range_factor,
								  bool					never_use,
								  double				weight )
	: t_abstract_combat_ai_action( battlefield, never_use, weight), m_target(target), 
	  m_range_factor(range_factor)
{

}

inline
t_combat_creature_ptr t_combat_ai_ranged_single_action::get_target() const
{
	return m_target;
}

inline
int t_combat_ai_ranged_single_action::get_range_factor() const
{
	return m_range_factor;
}

#endif // COMBAT_AI_RANGED_SINGLE_ACTION_H_INCLUDED
